//# sourceURL=http://uMapApp/UI/Panel/PanelBlock/Filter
define([
    "mhjs/mhjs",
    "../../Search"
], function (
    mhjs,
    Search
) {

    function Filter(option) {

        var _this = this;
        _this.ui = _this.ui || {};
        _this._filter = new mhjs.Filter();

        _this._filter.on("update", function () {
            _this.trigger("update");
        });

        Search.call(_this, option);
        _this.addClass("filter");

        _this.on("change", function () {
            _this.update();
        });


    }

    var _class = Filter;
    mhjs.Inherit(_class, Search);


    Object.defineProperties(_class.prototype, {
        "list"  : {
            set: function (list) {
                var _this = this;
                _this._filter.list = list;
            },
            get: function () {
                return this._filter.list;
            }
        },
        "filter": {
            get: function () {
                return this._filter;
            }
        },
        "param" : {
            set: function (param) {
                var _this = this;
                _this._param = param;
            },
            get: function () {
                return this._param;
            }
        },
        "update": {
            value: function () {
                var _this = this;
                if (_this.filter.list && _this.param) {

                    _this.filter.condition = function (item) {
                        if (item.getChainChild(_this.param)) {

                            var nook = true;
                            var arr = _this.value.split(" ");

                            $.each(arr, function (i, keyword) {
                                if (item.getChainChild(_this.param).search(keyword) < 0) {
                                    nook = false;
                                    return false;
                                }
                            });


                            return nook;
                        }
                    };
                }
            }
        }
    });

    return _class;

});